<?

if (!empty($_COOKIE['user'])) {
  header('Location: dashboard.php');
}

include("header.inc.php");

?>

  <h1>Log In</h1>
  
<?
if (isset($_GET['success'])) {
  $success_info = $_GET['success'];
  $success_info = explode('_', $success_info);
  echo '<p class="success">'.$success_info[0].' '.$success_info[1].' successfully.</p>';
}

if (isset($_GET['failure'])) {
  if ($_GET['failure'] == 'login') {
    echo '<p class="error">Email or password incorrect, please try again.</p>';
  }
  else if ($_GET['failure'] == 'email') {
    echo '<p class="error">An account with this email address already exists.</p>';
  }
}
?>
  
  <form name="login" action="login.php" method="post">
    <p>
      <label for="username">Email Address:</label><br/>
      <input type="email" name="username" id="username">
    </p>
    <p>
      <label for="password">Password:</label><br/>
      <input type="password" name="password" id="password">
    </p>
    
    <input type="submit" name="action" value="Log In">
    or
    <a href="new_user.php">Create Account</a>
  </form>

  <p class="legal">
    Organization Organizer &copy; James Godfrey-Kittle.
    All rights reserved.
  </p>

<?

include("footer.inc.php");

?>
